package com.ffapp.demo.bean;


import java.util.ArrayList;
import java.util.Iterator;

public class HomeAppGroupListBean extends BaseListBeanBc {



    private ArrayList<HomeGrideListBean> list = new ArrayList<HomeGrideListBean>();


    public ArrayList<HomeGrideListBean> getList() {
        return list;
    }

    public void setList(ArrayList<HomeGrideListBean> list) {
        this.list = list;
    }

    public boolean isHaveClassify(String classify){
        if(list.size() == 0)return false;
        for(HomeGrideListBean listBean:list){
            if(listBean.getClassify().equals(classify)){
                return true;
            }
        }
        return false;
    }

    public void addHomeGridData(HomeGrideListData data){
        for(HomeGrideListBean listBean:list){
            if(listBean.getClassify().equals(data.getClassify())){
                listBean.getList().add(data);
                return;
            }
        }
    }

    public void removeGridData(HomeGrideListData data){
        Iterator<HomeGrideListData> iterator;
        HomeGrideListData homeGrideListData;
        for(HomeGrideListBean listBean:list){
            if(listBean.getClassify().equals(data.getClassify())){
                 iterator = listBean.getList().iterator();
                while (iterator.hasNext()){
                    homeGrideListData = iterator.next();
                    if(data.getName().equals(homeGrideListData.getName())){
                        iterator.remove();
                        return;
                    }
                }
            }
        }
    }
}
